<div class="comments index">
<h2><?php __('Comments');?></h2>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Comment', true), array('action'=>'add')); ?></li>
	</ul>
</div>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<?php echo $javascript->link('jquery', false) ?>
<?php //echo $form->create('Comment', array('action'=>'/admin/comments/'));?>
<form id="Comment" method="post" action="/admin/comments/index">
<?php echo $form->submit(__('Delete marked', true));?>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><input type="checkbox" id="selectall"></th>	
	<th><?php echo $paginator->sort('approved');?></th>
	<th><?php echo $paginator->sort('created');?></th>
	<th><?php echo $paginator->sort('ref_url');?></th>
	

</tr>
<?php
$i = 0;
foreach ($comments as $comment):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			
			<?php echo $form->checkbox($comment['Comment']['id'].'.Comments.delete'); ?>
		</td>
		<td>
			<strong><?php echo $comment['Comment']['author']; ?><strong><br />
			<?php echo $html->link($comment['Comment']['email'], 'mailto:'.$comment['Comment']['email']); ?><br />
			
			
			<?php 
			$ip_lookup = 'http://ws.arin.net/whois/?queryinput=' . $comment['Comment']['ip'];
			echo $html->link($comment['Comment']['ip'], $ip_lookup); ?>
		</td>
		<td>
			<?php __('Created on')?> <?php echo $html->link( $time->niceShort($comment['Comment']['created']), array('action'=>'view', $comment['Comment']['id'])); ?>
			 
			<p>
				<?php echo $comment['Comment']['body']; ?>
			</p>
			<p><?php 
				if($comment['Comment']['approved'] == 1)
					__('Approved');
				else 
					__('Unpproved');
				?> |
				<?php echo $html->link(__('Edit', true), array('action'=>'edit', $comment['Comment']['id'])); ?> |
				<?php echo $html->link(__('Delete', true), array('action'=>'delete', $comment['Comment']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $comment['Comment']['id'])); ?>
			</p>
		</td>
		<td>
			<?php 
			$url = substr($comment['Comment']['ref_url'], strrpos($comment['Comment']['ref_url'],'/') + 1 );
			echo $html->link($url, $comment['Comment']['ref_url']); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
<?php echo $form->submit(__('Delete marked', true));?>
<?php echo $form->end();?>
</div>

<script>

jQuery(document).ready(function() {
	jQuery("#selectall").click(function()
	{
		//alert(this);
		var checked_status = this.checked;
		jQuery("input[type='checkbox']").each(function()
		{
			this.checked = checked_status;
		});
	});
});
</script>

<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Comment', true), array('action'=>'add')); ?></li>
	</ul>
</div>
